package com.exam.api.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.exam.api.dao.ExamStudentDao;
import com.exam.api.dto.ExamStudentDTO;
import com.exam.api.service.ExamStudentService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @description: 学生考试管理业务层实现类
* @author: wuming
* @create: 2024.05.03 13:24:03
*/
@Service("examStudentService")
public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentDao, ExamStudentDTO> implements ExamStudentService {

    @Override
    public Page<ExamStudentDTO> basePage(ExamStudentDTO examStudentDTO) {
        if (null != examStudentDTO.getCurrent() && null != examStudentDTO.getPageSize())
            examStudentDTO.setCurrent((examStudentDTO.getCurrent() - 1) * examStudentDTO.getPageSize());
        List<ExamStudentDTO> list = this.baseMapper.findList(examStudentDTO);
        int count = this.baseMapper.findPageCount(examStudentDTO);
        Page<ExamStudentDTO> page = new Page<>();
        page.setTotal(count);
        page.setRecords(list);
        return page;
    }

    @Override
    public List<ExamStudentDTO> findList(ExamStudentDTO examStudentDTO) {
        return this.baseMapper.findList(examStudentDTO);
    }

}
